package com.atguigui.leetcode1;

/**
 * 1401. 圆和矩形是否有重叠
 * Project: leetcode
 * Package: com.atguigui.leetcode1
 * Version: 1.0
 * <p>
 * Created by WJX on 2023/6/25 9:42
 */
public class P1401CircleAndRectangleOverlapping {
    public static void main(String[] args) {

    }

    class Solution {
        public boolean checkOverlap(int radius, int xCenter, int yCenter, int x1, int y1, int x2, int y2) {

            double disk = 0;
            if (xCenter < x1 || xCenter > x2) {
                disk += Math.min(Math.pow(x1 - xCenter, 2), Math.pow(x2 - xCenter, 2));
            }
            if (yCenter < y1 || yCenter > y2) {
                disk += Math.min(Math.pow(y1 - yCenter, 2), Math.pow(y2 - yCenter, 2));
            }

            return disk <= radius * radius;
        }
    }
}
